

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>MDS Journaling &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="文件布局" href="../file-layouts/" />
    <link rel="prev" title="与 POSIX 标准的差异" href="../posix/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../">Ceph 文件系统</a> &raquo;</li>
        
      <li>MDS Journaling</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/cephfs/mds-journaling.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id4">管理</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id6">CephFS 内幕</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../mds-states/"> MDS 的各种状态</a></li>
<li class="toctree-l3"><a class="reference internal" href="../posix/"> POSIX 兼容性</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> MDS 日志记录</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#cephfs-metadata-pool">CephFS Metadata Pool</a></li>
<li class="toctree-l4"><a class="reference internal" href="#cephfs-mds-journaling">CephFS MDS Journaling</a></li>
<li class="toctree-l4"><a class="reference internal" href="#journal-events">Journal Events</a></li>
<li class="toctree-l4"><a class="reference internal" href="#journal-event-types">Journal Event Types</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../file-layouts/"> 文件布局</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mdcache/"> 分布式元数据缓存</a></li>
<li class="toctree-l3"><a class="reference internal" href="../dynamic-metadata-management/"> CephFS 内的动态元数据管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-io-path/"> CephFS IO 路径</a></li>
<li class="toctree-l3"><a class="reference internal" href="../lazyio/"> LazyIO</a></li>
<li class="toctree-l3"><a class="reference internal" href="../dirfrags/"> 目录分片的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../multimds/"> 多活 MDS 的配置</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="mds-journaling">
<h1>MDS Journaling<a class="headerlink" href="#mds-journaling" title="Permalink to this headline">¶</a></h1>
<div class="section" id="cephfs-metadata-pool">
<h2>CephFS Metadata Pool<a class="headerlink" href="#cephfs-metadata-pool" title="Permalink to this headline">¶</a></h2>
<p>CephFS uses a separate (metadata) pool for managing file metadata (inodes and
dentries) in a Ceph File System. The metadata pool has all the information about
files in a Ceph File System including the File System hierarchy. Additionally,
CephFS maintains meta information related to other entities in a file system
such as file system journals, open file table, session map, etc.</p>
<p>This document describes how Ceph Metadata Servers use and rely on journaling.</p>
</div>
<div class="section" id="cephfs-mds-journaling">
<h2>CephFS MDS Journaling<a class="headerlink" href="#cephfs-mds-journaling" title="Permalink to this headline">¶</a></h2>
<p>CephFS metadata servers stream a journal of metadata events into RADOS in the metadata
pool prior to executing a file system operation. Active MDS daemon(s) manage metadata
for files and directories in CephFS.</p>
<p>CephFS uses journaling for couple of reasons:</p>
<ol class="arabic simple">
<li><p>Consistency: On an MDS failover, the journal events can be replayed to reach a
consistent file system state. Also, metadata operations that require multiple
updates to the backing store need to be journaled for crash consistency (along
with other consistency mechanisms such as locking, etc..).</p></li>
<li><p>Performance: Journal updates are (mostly) sequential, hence updates to journals
are fast. Furthermore, updates can be batched into single write, thereby saving
disk seek time involved in updates to different parts of a file. Having a large
journal also helps a standby MDS to warm its cache which helps indirectly during
MDS failover.</p></li>
</ol>
<p>Each active metadata server maintains its own journal in the metadata pool. Journals
are striped over multiple objects. Journal entries which are not required (deemed as
old) are trimmed by the metadata server.</p>
</div>
<div class="section" id="journal-events">
<h2>Journal Events<a class="headerlink" href="#journal-events" title="Permalink to this headline">¶</a></h2>
<p>Apart from journaling file system metadata updates, CephFS journals various other events
such as client session info and directory import/export state to name a few. These events
are used by the metadata sever to reestablish correct state as required, e.g., Ceph MDS
tries to reconnect clients on restart when journal events get replayed and a specific
event type in the journal specifies that a client entity type has a session with the MDS
before it was restarted.</p>
<p>To examine the list of such events recorded in the journal, CephFS provides a command
line utility <cite>cephfs-journal-tool</cite> which can be used as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cephfs</span><span class="o">-</span><span class="n">journal</span><span class="o">-</span><span class="n">tool</span> <span class="o">--</span><span class="n">rank</span><span class="o">=&lt;</span><span class="n">fs</span><span class="o">&gt;</span><span class="p">:</span><span class="o">&lt;</span><span class="n">rank</span><span class="o">&gt;</span> <span class="n">event</span> <span class="n">get</span> <span class="nb">list</span>
</pre></div>
</div>
<p><cite>cephfs-journal-tool</cite> is also used to discover and repair a damaged Ceph File System.
(See <a class="reference internal" href="../cephfs-journal-tool/"><span class="doc">cephfs-journal-tool</span></a> for more details)</p>
</div>
<div class="section" id="journal-event-types">
<h2>Journal Event Types<a class="headerlink" href="#journal-event-types" title="Permalink to this headline">¶</a></h2>
<p>Following are various event types that are journaled by the MDS.</p>
<ol class="arabic simple">
<li><p><cite>EVENT_COMMITTED</cite>: Mark a request (id) as committed.</p></li>
<li><p><cite>EVENT_EXPORT</cite>: Maps directories to an MDS rank.</p></li>
<li><p><cite>EVENT_FRAGMENT</cite>: Tracks various stages of directory fragmentation (split/merge).</p></li>
<li><p><cite>EVENT_IMPORTSTART</cite>: Logged when an MDS rank starts importing directory fragments.</p></li>
<li><p><cite>EVENT_IMPORTFINISH</cite>: Logged when an MDS rank finishes importing directory fragments.</p></li>
<li><p><cite>EVENT_NOOP</cite>: No operation event type for skipping over a journal region.</p></li>
<li><p><cite>EVENT_OPEN</cite>: Tracks which inodes have open file handles.</p></li>
<li><p><cite>EVENT_RESETJOURNAL</cite>: Used to mark a journal as <cite>reset</cite> post truncation.</p></li>
<li><p><cite>EVENT_SESSION</cite>: Tracks open client sessions.</p></li>
<li><p><cite>EVENT_SLAVEUPDATE</cite>: Logs various stages of an operation that has been forwarded to a (slave) mds.</p></li>
<li><p><cite>EVENT_SUBTREEMAP</cite>: Map of directory inodes to directory contents (subtree partition).</p></li>
<li><p><cite>EVENT_TABLECLIENT</cite>: Log transition states of MDSs view of client tables (snap/anchor).</p></li>
<li><p><cite>EVENT_TABLESERVER</cite>: Log transition states of MDSs view of server tables (snap/anchor).</p></li>
<li><p><cite>EVENT_UPDATE</cite>: Log file operations on an inode.</p></li>
</ol>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../file-layouts/" class="btn btn-neutral float-right" title="文件布局" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../posix/" class="btn btn-neutral float-left" title="与 POSIX 标准的差异" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>